package com.doctor.demo;

import java.io.BufferedReader;

import com.doctor.base.SysController;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class HelloController extends SysController{

	public void index(){
		renderText("Hello Jfinal World");
//		Record code = new Record().set("id", "321").set("c_code_name", "0.11").set("c_code_value", "00148B46");
//		Db.save("code", code);
	}
	
	public void debtest(){
		renderJson("{}");
//		Record code = new Record().set("c_code_name", "0.11").set("c_code_value", "00148B46");
//		Db.save("code", code);
	}
	
//	@Before(POST.class)
	public String getData(){
		StringBuilder json = new StringBuilder();
		try{
			
			BufferedReader reader = this.getRequest().getReader();
			String line = null;
			
			while((line = reader.readLine()) != null){
				json.append(line);
			}
			reader.close();
			
		}catch(Exception e){
			return "";
		}
		renderJson(json.toString());
		return json.toString();
	}
}
